let mysql=require('mysql');

let db=mysql.createConnection({
    host:'localhost',
    user:'root',
    password:'root',
    database:'tiantianpeiwan',
    timezone:'08:00'
});


let xmpayOrderModule={
    getmjxpay:function (JD_co,U_id,fn) {
        let sql=`SELECT a.JD_co JD,e.U_falsename PFname,
 d.G_names PGname, a.JD_hours XDsum, b.PU_price Pprice,
a.JD_money XDmoney
FROM p_jdtable a
LEFT JOIN p_user c ON a.U_co=c.U_co
LEFT JOIN p_playuser b ON a.PU_cid=b.PU_cid  
LEFT JOIN p_user e ON b.U_co=e.U_co 
LEFT JOIN p_game d ON b.G_id=d.G_id
WHERE a.JD_co="${JD_co}" AND c.U_id="${U_id}"`;
        db.query(sql,function (err,data) {
            fn(err,data)
        })
    },
    xmpayok:function (JD_co,JD_puon,XDzfdate,fn) {
        let sql=`UPDATE p_jdtable SET JD_puon="${JD_puon}",
         JD_zfdatetimes="${XDzfdate}" WHERE JD_co="${JD_co}"`;
        db.query(sql,function (err,data) {
            fn(err,data)
        })
    },

};

module.exports=xmpayOrderModule;